<%--
    Document   : rslistfood
    Created on : Nov 13, 2011, 9:08:54 AM
    Author     : Venus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.*, java.text.NumberFormat, Beans.ThamSoHT,Models.ThamSoHT_Model, Models.NhomMA_Model, Models.MonAn_Model, Models.TienTe_Model"%>
<%
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = " 'updateoptionfood', 'noserve', 'serve', 'status', 'rightmsg', 'price', 'notice', 'image', 'foodname', 'foodlist',  'abbreviation', 'all', 'disable', 'enable', 'foodgroups' ";
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.

            String abbreviation = mdsts[0].getTenTS();
            String all = mdsts[1].getTenTS();
            String disable = mdsts[2].getTenTS();
            String enable = mdsts[3].getTenTS();
            String foodgroups = mdsts[4].getTenTS();
            String foodlist = mdsts[5].getTenTS();
            String foodname = mdsts[6].getTenTS();
            String image = mdsts[7].getTenTS();
            String noserve = mdsts[8].getTenTS();
            String notice = mdsts[9].getTenTS();
            String price = mdsts[10].getTenTS();
            String rightmsg = mdsts[11].getTenTS();
            String serve = mdsts[12].getTenTS();
            String status = mdsts[13].getTenTS();
            String updateoptionfood = mdsts[14].getTenTS();

            String msgright = notice + "/" + rightmsg;
            Vector vDSMA = (Vector) request.getAttribute("DSMA");
            Vector vDSNMA = (Vector) request.getAttribute("DSNMA");
            int numpage = 0;// khởi tạo số trang = 0
            int vsize = vDSMA.size();
            if (vsize % 6 == 0) // mỗi trang có 6 dòng
            {
                numpage = vsize / 6;
            } else {
                numpage = vsize / 6 + 1;
            }
            String xx = (String) request.getAttribute("item"); // trang hiện tại đang xem
            int item = Integer.parseInt(xx);
            String sapxep = (String) request.getAttribute("order");
            String test = (String) request.getAttribute("test");
            String sort = (String) request.getAttribute("sort");
            String sortkv = (String) request.getAttribute("sortkv");
            String sx1 = "";
            String sx2 = "";
            String sx3 = "";
            String sx5 = "";
            String sx6 = "";
            String ud1 = "";
            String ud2 = "";
            String ud3 = "";
            String ud6 = "";
            String ud5 = "";
            if (sapxep.equals("desc")) {
                sx1 = "down";
                sx2 = "down";
                sx3 = "down";
                sx5 = "down";
                sx6 = "down";
                ud1 = "down1";
                ud6 = "down2";
                ud2 = "down1";
                ud3 = "down1";
                ud5 = "down1";
            } else if (sapxep.equals("asc") && test.equals("1")) {
                sx1 = "up";
                sx2 = "down";
                sx3 = "down";
                sx5 = "down";
                sx6 = "down";
                ud1 = "up1";
                ud2 = "down1";
                ud3 = "down1";
                ud5 = "down1";
                ud6 = "down2";
            } else if (sapxep.equals("asc") && test.equals("2")) {
                sx1 = "down";
                sx2 = "up";
                sx3 = "down";
                sx5 = "down";
                sx6 = "down";
                ud1 = "down1";
                ud2 = "up1";
                ud3 = "down1";
                ud5 = "down1";
                ud6 = "down2";
            } else if (sapxep.equals("asc") && test.equals("3")) {
                sx1 = "down";
                sx2 = "down";
                sx5 = "down";
                sx3 = "up";
                sx6 = "down";
                ud1 = "down1";
                ud2 = "down1";
                ud5 = "down1";
                ud3 = "up1";
                ud6 = "down2";
            } else if (sapxep.equals("asc") && test.equals("6")) {
                sx1 = "down";
                sx2 = "down";
                sx3 = "down";
                sx5 = "down";
                sx6 = "up";
                ud1 = "down1";
                ud2 = "down1";
                ud3 = "down1";
                ud5 = "down1";
                ud6 = "up2";
            } else if (sapxep.equals("asc") && test.equals("5")) {
                sx1 = "down";
                sx2 = "down";
                sx3 = "down";
                sx5 = "up";
                sx6 = "down";
                ud1 = "down1";
                ud2 = "down1";
                ud3 = "down1";
                ud5 = "up1";
                ud6 = "down2";
            }
            NumberFormat nf = NumberFormat.getNumberInstance(Locale.FRENCH);

%>
<div class="title">
    <%=foodlist%>
    <a href="#" lang="<%=msgright%>" onclick="AddFood(this.lang)" style=" float: right; margin-top: 3px;" ><img alt="" style=" width: 30px; height: 30px;" src="../images/add1.png"></a>
</div>
<div class="content">
    <form name="dsma" action="">
        <table class="mytable" border="0" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th style="width: 5%;  ">STT</th>
                    <th style="width: 15%; ">
                        <a href="#" id="titledskv1" style="margin-top: 5px;" class="<%=sx1%>" lang="<%=msgright%>"  name="1" onclick="SortTenNMA(this.className, this.name)">
                            <div style="float:left"><%=foodgroups%></div>
                            <div id="sortkv1" style=" margin-right: 30px;" class="<%=ud1%>"></div>
                        </a>
                    </th>
                    <th style="width: 17%; ">
                        <a href="#" id="titledskv2" style="margin-top: 5px;" class="<%=sx2%>" lang="<%=msgright%>"  name="1" onclick="SortTenMA(this.className, this.name)">
                            <div style="float:left"><%=foodname%></div>
                            <div id="sortkv2" style=" margin-right: 55px;" class="<%=ud2%>"></div>
                        </a>
                    </th>
                    <th style="width: 14%; ">
                        <a href="#" id="titledskv3" style="margin-top: 5px;" class="<%=sx3%>" lang="<%=msgright%>"  name="1" onclick="SortTenVT(this.className, this.name)">
                            <div style="float:left"><%=abbreviation%></div>
                            <div id="sortkv3" style=" margin-right: 25px;" class="<%=ud3%>"></div>
                        </a>
                    </th>
                    <th style="width: 16%; ">
                        <a href="#" id="titledskv4" style="margin-top: 5px;" class="down" lang="<%=msgright%>"  name="1" >
                            <div style=""><%=image%></div>

                        </a>
                    </th>
                    <th style="width: 14%; ">
                        <a href="#" id="titledskv5" style="margin-top: 5px;" class="<%=sx5%>" lang="<%=msgright%>"  name="1" onclick="SortGiaMA(this.className, this.name)">
                            <div style="float:left"><%=price%> (<%=TienTe_Model.LayKyHieuTT(langid) %>)</div>
                            <div id="sortkv5" style=" margin-right: 45px;" class="<%=ud5%>"></div>
                        </a>
                    </th>
                    <th style=" margin-top: 2px;">
                        <a href="#" id="titledskv6" class="<%=sx6%>"  name="1" lang="<%=msgright%>" onclick="SortTTMA(this.className, this.name)">
                            <div><%=status%></div>
                            <div>
                                <div  id="sortkv6" class="<%=ud6%>"></div>
                            </div>
                        </a>
                    </th>
                    <th></th>
                </tr>
                <tr id="searchMA">
                    <th><img style=" margin-top: 2px; margin-left: 3px; margin-bottom: -7px; cursor: pointer;"  alt="1" src="../images/search1.png" lang="<%=msgright%>" onclick="SearchMA(this.alt)"></th>
                    <th>
                        <select name="1" class="nhommonan" id="1" style=" width: 110px;" lang="<%=msgright%>" onchange="SearchMA(this.name, this.lang)">
                            <option value="all"><%= all%></option>
                            <%
                                        for (int k = 0; k < vDSNMA.size(); k++) {
                                            Beans.NhomMA nma = (Beans.NhomMA) vDSNMA.elementAt(k);
                            %>       <option value="<%=nma.getMaNMA()%>"><%=nma.getTenNMA()%></option>
                            <%  }
                            %>
                        </select>
                    </th>
                    <th><input type="textbox" style="width: 110px;" name="TENMA" class="TENMA text" ></th>
                    <th><input type="textbox" style="width: 90px;" name="TENVT" class="TENVT text" ></th>
                    <th></th>
                    <th><input type="textbox" style="width: 80px;" name="GIA" class="GIA text" onkeypress="return keypress(event)" ></th>
                    <th>
                        <select class="TINHTRANG" name="1" lang="<%=msgright%>" onchange="SearchMA(this.name, this.lang)">
                            <option value="all"><%= all%></option>
                            <option value="1"><%=serve%></option>
                            <option value="0"><%=noserve%></option>
                        </select>
                    </th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                <%
                            for (int i = (item - 1) * 6; i < (item - 1) * 6 + 6 && i < vsize; i++) {
                                Beans.MonAn ma = (Beans.MonAn) vDSMA.elementAt(i);
                %>
                <tr>
                    <td class="STT"><%= i + 1%></td>
                    <td><%=NhomMA_Model.LayTenNhomMA(ma.getMaNMA(), langid)%></td>
                    <td><a href="#" name="<%=ma.getMaMA()%>" lang="<%=msgright%>" onclick="ShowLangMA(this.name, this.lang)"><%= ma.getTenMA()%></a></td>
                    <td><%= ma.getTenMAVT()%></td>
                    <td>
                        <a href="#<%=ma.getMaMA()%>">
                            <img style=" width: 100px; height: 60px;" alt="LightBox" src="../images/foodimages/<%=MonAn_Model.LayTenHinhAnh(ma.getMaMA())%>">
                        </a>
                        <div id="<%=ma.getMaMA()%>" class="lb">
                            <a href="#top">
                                <img alt="oh man" style="max-width: 500px; max-height: 400px;" src="../images/foodimages/<%=MonAn_Model.LayTenHinhAnh(ma.getMaMA())%>">
                            </a>
                        </div>
                    </td>
                    <td><div style=" width: 65px; text-align: right;"><%=nf.format(MonAn_Model.LayGia(ma.getMaMA())) %></div></td>
                    <td>
                        <select  class="<%= ma.getMaMA()%>" lang="<%=msgright%>" onchange="UpdateStatusMA(this.value,  this.className)">
                            <%
                                                            if (ma.getCoPhucVu() == 1) {%>
                            <option value="1"><%=serve%></option>
                            <option value="0"><%=noserve%></option>
                            <%  } else {%>
                            <option value="0"><%=noserve%></option>
                            <option value="1"><%=serve%></option>
                            <%  }
                            %>
                        </select>
                    </td>
                    <td><a href="#" name="<%=msgright%>" id="<%=ma.getMaMA()%>" title="<%=updateoptionfood%>" onclick="OptionFood(this.name, this.id)" lang="<%=msgright%>" ><img style="width: 17px; margin-top: 2px;" alt="" src="../images/edit.png"></a></td>
                </tr>
                <%  }
                %>
            </tbody>
        </table>
        <div class="pagination">
            <%
                        int trang = 1;
                        if (item > 1) {
                            trang = item - 1;
                        }
            %>
            <%
                        if (vsize > 10) {%>
            <%
                                        if (sortkv.equals("tennma")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="prev"  name="<%= trang%>"  onclick="SortTenNMA(this.id, this.name, this.lang)">«</a>
            <%  } else if (sortkv.equals("tenma")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="prev"  name="<%= trang%>" onclick="SortTenMA(this.id, this.name, this.lang)">«</a>
            <%  } else if (sortkv.equals("tenvt")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="prev"  name="<%= trang%>" onclick="SortTenVT(this.id, this.name, this.lang)">«</a>
            <%  } else if (sortkv.equals("tengiama")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="prev"  name="<%= trang%>" onclick="SortGiaMA(this.id, this.name, this.lang)">«</a>
            <%  } else {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="prev"  name="<%= trang%>" onclick="SortTTMA(this.id, this.name, this.lang)">«</a>
            <%  }
            %>
            <%
                                        for (int c = 1; c <= numpage; c++) {
                                            if (numpage < 10) {
                                                if (c != item) {%>
            <%
                                                                        if (sortkv.equals("tennma")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%=c%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%=c%></a>
            <%  } else if (sortkv.equals("tenma")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"   name="<%=c%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%=c%></a>
            <%  } else if (sortkv.equals("tenvt")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"   name="<%=c%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%=c%></a>
            <%  } else if (sortkv.equals("tengiama")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%=c%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%=c%></a>
            <%  } else {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%=c%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%=c%></a>
            <%  }
            %>
            <%                } else {%>
            <a class="current"> <%= c%></a>
            <%                }
                                                                } else {
                                                                    if (c == item && item == 1) {%>
            <%
                                                                                    if (sortkv.equals("tennma")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current" name="<%= item%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 1%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= item + 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 2%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= item + 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 3%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= item + 3%></a>
            ...
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage - 3%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= numpage - 3%></a>
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= numpage - 2%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= numpage - 2%></a>
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= numpage - 1%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= numpage - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= numpage%></a>
            <%  } else if (sortkv.equals("tenma")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current" name="<%= item%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 1%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= item + 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 2%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= item + 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 3%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= item + 3%></a>
            ...
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage - 3%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= numpage - 3%></a>
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= numpage - 2%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= numpage - 2%></a>
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= numpage - 1%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= numpage - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= numpage%></a>
            <%  } else if (sortkv.equals("tenvt")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current" name="<%= item%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 1%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= item + 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 2%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= item + 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 3%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= item + 3%></a>
            ...
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage - 3%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= numpage - 3%></a>
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= numpage - 2%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= numpage - 2%></a>
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= numpage - 1%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= numpage - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= numpage%></a>
            <%  } else if (sortkv.equals("tengiama")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current" name="<%= item%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 1%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= item + 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 2%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= item + 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 3%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= item + 3%></a>
            ...
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage - 3%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= numpage - 3%></a>
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= numpage - 2%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= numpage - 2%></a>
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= numpage - 1%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= numpage - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= numpage%></a>
            <%  } else {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current" name="<%= item%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 1%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= item + 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 2%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= item + 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 3%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= item + 3%></a>
            ...
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage - 3%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= numpage - 3%></a>
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= numpage - 2%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= numpage - 2%></a>
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= numpage - 1%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= numpage - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= numpage%></a>
            <%  }
            %>

            <%            }
                                                                    if (c == item && item != 1) {
                                                                        if (item < (numpage / 2)) {%>
            <%
                                                                                        if (sortkv.equals("tennma")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 1%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 1%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= item + 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 2%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= item + 2%></a>
            ...
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= numpage - 3%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= numpage - 3%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage - 2%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= numpage - 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage - 1%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= numpage - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= numpage%></a>
            <%  } else if (sortkv.equals("tenma")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 1%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 1%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= item + 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 2%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= item + 2%></a>
            ...
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= numpage - 3%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= numpage - 3%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage - 2%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= numpage - 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage - 1%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= numpage - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= numpage%></a>
            <%  } else if (sortkv.equals("tenvt")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 1%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 1%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= item + 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 2%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= item + 2%></a>
            ...
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= numpage - 3%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= numpage - 3%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage - 2%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= numpage - 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage - 1%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= numpage - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= numpage%></a>
            <%  } else if (sortkv.equals("tengiama")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 1%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 1%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= item + 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 2%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= item + 2%></a>
            ...
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= numpage - 3%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= numpage - 3%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage - 2%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= numpage - 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage - 1%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= numpage - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= numpage%></a>
            <%  } else {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 1%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 1%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= item + 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 2%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= item + 2%></a>
            ...
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= numpage - 3%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= numpage - 3%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage - 2%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= numpage - 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage - 1%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= numpage - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= numpage%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= numpage%></a>
            <%  }
            %>

            <%                }%>
            <%                                     if (item >= (numpage / 2) && item != numpage) {
                                                                                        int start = 1;
            %>
            <%
                                                     if (sortkv.equals("tennma")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= start%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 1%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= start + 1%></a>
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= start + 2%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= start + 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 3%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= start + 3%></a>
            ...
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 2%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= item - 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 1%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 1%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= item + 1%></a>
            <%  } else if (sortkv.equals("tenma")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= start%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 1%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= start + 1%></a>
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= start + 2%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= start + 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 3%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= start + 3%></a>
            ...
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 2%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= item - 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 1%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 1%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= item + 1%></a>
            <%  } else if (sortkv.equals("tenvt")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= start%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 1%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= start + 1%></a>
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= start + 2%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= start + 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 3%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= start + 3%></a>
            ...
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 2%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= item - 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 1%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 1%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= item + 1%></a>
            <%  } else if (sortkv.equals("tengiama")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= start%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 1%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= start + 1%></a>
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= start + 2%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= start + 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 3%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= start + 3%></a>
            ...
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 2%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= item - 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 1%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 1%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= item + 1%></a>
            <%  } else {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= start%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 1%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= start + 1%></a>
            <a href="#"  id="<%=sort%>"  lang="<%=msgright%>" name="<%= start + 2%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= start + 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 3%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= start + 3%></a>
            ...
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 2%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= item - 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 1%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= item%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item + 1%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= item + 1%></a>
            <%  }

            %>

            <%                }
            %>
            <%                                     if (item >= (numpage / 2) && item == numpage) {
                                                                                        int start = 1;
            %>
            <%
                                                     if (sortkv.equals("tennma")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= start%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 1%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= start + 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 2%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= start + 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 3%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= start + 3%></a>
            ...
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 3%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= item - 3%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 2%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= item - 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 1%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="SortTenNMA(this.id, this.name, this.lang)"><%= item%></a>
            <%  } else if (sortkv.equals("tenma")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= start%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 1%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= start + 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 2%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= start + 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 3%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= start + 3%></a>
            ...
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 3%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= item - 3%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 2%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= item - 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 1%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="SortTenMA(this.id, this.name, this.lang)"><%= item%></a>
            <%  } else if (sortkv.equals("tenvt")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= start%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 1%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= start + 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 2%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= start + 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 3%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= start + 3%></a>
            ...
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 3%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= item - 3%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 2%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= item - 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 1%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="SortTenVT(this.id, this.name, this.lang)"><%= item%></a>
            <%  } else if (sortkv.equals("tengiama")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= start%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 1%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= start + 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 2%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= start + 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 3%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= start + 3%></a>
            ...
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 3%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= item - 3%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 2%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= item - 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 1%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="SortGiaMA(this.id, this.name, this.lang)"><%= item%></a>
            <%  } else {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= start%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 1%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= start + 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 2%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= start + 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= start + 3%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= start + 3%></a>
            ...
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 3%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= item - 3%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 2%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= item - 2%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>"  name="<%= item - 1%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= item - 1%></a>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="current"  name="<%= item%>" onclick="SortTTMA(this.id, this.name, this.lang)"><%= item%></a>
            <%  }
            %>
            <%                }
            %>
            <%            }
                                            }
                                        }
            %>
            <%
                                        if (item + 1 <= numpage) {
                                            trang = item + 1;
                                        } else {
                                            trang = item;
                                        }
            %>
            <%
                                        if (sortkv.equals("tennma")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="next"  name="<%= trang%>" onclick="SortTenNMA(this.id, this.name, this.lang)">»</a>
            <%  } else if (sortkv.equals("tenma")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="next"  name="<%= trang%>" onclick="SortTenMA(this.id, this.name, this.lang)">»</a>
            <%  } else if (sortkv.equals("tenvt")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="next"  name="<%= trang%>" onclick="SortTenVT(this.id, this.name, this.lang)">»</a>
            <%  } else if (sortkv.equals("tengiama")) {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="next"  name="<%= trang%>" onclick="SortGiaMA(this.id, this.name, this.lang)">»</a>
            <%  } else {%>
            <a href="#" id="<%=sort%>"  lang="<%=msgright%>" class="next"  name="<%= trang%>" onclick="SortTTMA(this.id, this.name, this.lang)">»</a>
            <%  }
            %>
            <%  }
            %>
        </div>
    </form>
</div>
